from SimpylScrape.Parsers import SiteParser, XpathParser
import os.path

class WootPage(SiteParser):
    class comment(XpathParser):
    	"""
    	.//div[@class='primaryContent']/div[@class='forumPost clearfix User']
    	"""
    	user = ".//span[@class='qtip']/h4//text()"
    	date = ".//ul[1]/li[1]/span//text()"
    	contents = ".//div[@class='content']/p[1]//text()"

class WootComments(SiteParser):
    """
    http://www.woot.com/Forums/
    """
    def page(url):
        """
        .//div[@class='forumPagination clearfix']//li[@class='pageNumbers']/a/@href
        """
        fullUrl = os.path.join(WootComments.__doc__.rsplit('/',1)[0], url).strip()
        return WootPage(fullUrl)()


